import { defineConfig } from 'rollup'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import PluginVue from 'rollup-plugin-vue'
import babel from '@rollup/plugin-babel'
import scss from 'rollup-plugin-scss'
import terser from '@rollup/plugin-terser'

export default defineConfig({
  input: 'src/index.js',
  output: [
    { file: 'dist/mengyuan-ui.esm.js', format: 'esm' },
    { file: 'dist/mengyuan-ui.esm.min.js', format: 'esm', plugins: [terser()] },
    { file: 'dist/mengyuan-ui.common.js', format: 'umd', name: 'MengyuanUI' },
    { file: 'dist/mengyuan-ui.common.min.js', format: 'umd', name: 'MengyuanUI', plugins: [terser()] }
  ],
  external: ['element-ui', 'vue'],
  plugins: [
    PluginVue(),
    resolve({ extensions: ['.vue', '.js', '.jsx'] }),
    commonjs(),
    babel({ babelHelpers: 'bundled' }),
    scss()
  ]
})
